/**
 * libx type defines
 *
 * bekars <bekars@gmail.com>
 *
 * History:
 * 	2011.10.09  bekars   implement type defines.
 *
 */

#ifndef __LIBX_TYPES_H__
#define __LIBX_TYPES_H__

//#include <sys/types.h>

#if !defined(HAVE_UINT8_T) || !defined(HAVE_U_INT8_T)
#    if !defined(HAVE_UINT8_T) && !defined(HAVE_U_INT8_T)
typedef unsigned char u_int8_t;
typedef unsigned char uint8_t;
#    elif defined(HAVE_UINT8_T)
typedef uint8_t  u_int8_t;
#    else
typedef u_int8_t uint8_t;
#    endif  /* !defined(HAVE_UINT8_T) && !defined(HAVE_U_INT8_T) */
#endif  /* !defined(HAVE_UINT8_T) || !defined(HAVE_U_INT8_T) */

#if !defined(HAVE_UINT16_T) || !defined(HAVE_U_INT16_T)
#    if !defined(HAVE_UINT16_T) && !defined(HAVE_U_INT16_T)
typedef unsigned short u_int16_t;
typedef unsigned short uint16_t;
#    elif defined(HAVE_UINT16_T)
typedef uint16_t  u_int16_t;
#    else
typedef u_int16_t uint16_t;
#    endif  /* !defined(HAVE_UINT16_T) && !defined(HAVE_U_INT16_T) */
#endif  /* !defined(HAVE_UINT16_T) || !defined(HAVE_U_INT16_T) */

#if !defined(HAVE_UINT32_T) || !defined(HAVE_U_INT32_T)
#    if !defined(HAVE_UINT32_T) && !defined(HAVE_U_INT32_T)
typedef unsigned int u_int32_t;
typedef unsigned int uint32_t;
#    elif defined(HAVE_UINT32_T)
typedef uint32_t  u_int32_t;
#    else
typedef u_int32_t uint32_t;
#    endif  /* !defined(HAVE_UINT32_T) && !defined(HAVE_U_INT32_T) */
#endif  /* !defined(HAVE_UINT32_T) || !defined(HAVE_U_INT32_T) */

#if !defined(HAVE_UINT64_T) || !defined(HAVE_U_INT64_T)
#    if !defined(HAVE_UINT64_T) && !defined(HAVE_U_INT64_T)
//typedef unsigned long int u_int64_t;
//typedef unsigned long int uint64_t;
#    elif defined(HAVE_UINT64_T)
//typedef uint64_t  u_int64_t;
#    else
//typedef u_int64_t uint64_t;
#    endif  /* !defined(HAVE_UINT64_T) && !defined(HAVE_U_INT64_T) */
#endif  /* !defined(HAVE_UINT64_T) || !defined(HAVE_U_INT64_T) */

#ifndef __int8_t_defined
#ifndef HAVE_INT8_T
typedef char int8_t;
#endif

#ifndef HAVE_INT16_T
typedef short int16_t;
#endif

#ifndef HAVE_INT32_T
#    if SIZEOF_LONG_INT == 4
typedef long int int32_t;
#    else
typedef int int32_t;
#    endif
#endif

#ifndef HAVE_INT64_T
#    if SIZEOF_LONG_LONG_INT == 8
typedef long long int int64_t;
#    else
typedef long int int64_t;
#    endif
#endif
#endif /* __int8_t_defined */

#ifndef UINT8_MAX
#  define UINT8_MAX  0xff
#endif

#ifndef USHRT_MAX
#  define USHRT_MAX  0xffff
#endif

#ifndef UINT16_MAX
#  define UINT16_MAX 0xffff
#endif

#ifndef UINT32_MAX
#  define UINT32_MAX (4294967295U)
#endif

#ifndef UINT64_MAX
#  if SIZEOF_UNSIGNED_LONG_INT == 8
#    define UINT64_MAX (18446744073709551615UL)
#  else
#    define UINT64_MAX (18446744073709551615ULL)
#  endif  /* SIZEOF_UNSIGNED_LONG_INT == 8 */
#endif  /* UINT64_MAX */

/** 
 * Somewhat arbitrary, but should be enough for this application
 * since files shouldn't be buried too deep.  This provides about
 * 15 levels of 255 character path components 
 */
#ifndef PATH_MAX
#  define PATH_MAX 4096
#endif

/* utilities */
#ifndef boolean
#  ifndef HAVE_BOOLEAN
typedef unsigned char boolean;
#  endif
#endif

#ifndef TRUE
# define TRUE 1
#endif

#ifndef FALSE
# define FALSE 0
#endif

#ifndef bool
typedef enum { false, true } _XBool;
#define bool _XBool
#endif

#endif /* __LIBX_TYPES_H__ */

